home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
cuj1008.zip
/
RAMEY.ZIP
/
PSORT.MAN
< prev
next >
Wrap
Text File
|
1991-10-06
|
5KB
|
149 lines
.in 5
NAME
psort - sort the standard input file
SYNOPSIS
psort [-t <dir>] [-s <record size>]
[ [-k <keys>] ] [ [-f <range>] [-c <range>] ]...
DESCRIPTION
psort sorts lines of the standard input file and writes the result
on the standard output. Default key is the entire line.
Default ordering is lexicographic by bytes in machine
collating sequence.
.in +4
.ti -4
-t use the following name for the temporary directory
default is taken from environment variable %TMP%
.ti -4
-s if a single value is specified, use a fixed length record of
the indicated number of bytes. If a range of sizes is specified,
assume variable length records upto the maximum size in the range.
Default is a variable length text record terminated by a newline character.
.ti
-k specify the collating sequence for the subsequently specified
sorting fields. The collating sequence is specified as one
or more ranges of values. Characters are assigned collating
sequence in order of their specification. For example,
to sort lower case alphabetic characters use -k 'a'-'z'.
Any characters not specified will be assigned a collating
value of 0. Characters in a field beyond a character with
a 0 collating value will not be included within the sorted field.
Hence, either of records b<0>a and b<0>c may precede the other
in the output file.
Within a key specification, any number of ranges may be
specified. For example, if the sorting field will contain
any combination of lower case letters, digits and spaces,
use -k ' ' '0'-'9' 'a'-'z'. Spaces will sort before digits
which will sort before lower case letters. If no key
collating sequence is specified, a default collating
sequence of all printable ascii characters is used.
.ti -4
-r repeat previous collating sequence. For example, to fold
upper case letters to lower case letters for purposes of
determining sorting priority use -k 'a'-'z' -r 'A'-'Z'.
This would assign the first character following the -r
the same collating value as the first one assigned in the
previous range. To give varying white space characters equal
weight use -k ' ' -r '\t' -r '_' .
.ti -4
-n numeric sort on the key. This is an alternative to -k.
numeric fields may contain a leading sign and/or decimal point.
Numeric fields should look like
[' ']...[+|-]['0'-'9']...[.]['0'-'9']...
Any non-numeric characters will terminate the field.
The field will be sorted by numeric value.
.ti -4
-i invert the sequence of the sort for the last key specified.
.ti -4
-u output only records that are unique according to the
sorting key fields.
.ti -4
-f sort on one or more fields. Fields are groups of
characters separated by a delimiter character.
Fields are number starting at 0. That is -f 0
refers to the start of the record.
A field specification may contain a range of
fields as in -f 2-4 to indicate that sorting
sequence is to be determined on the basis of
the third, fourth and fifth fields in turn.
A range must have a definite end. ie -f 2-
is not permited. A field range need not
be increasing. ie -f 3-2 is permited and
will sort first by the fourth then by the
third field.
.ti -4
-c sort one or more characters within the indicated
fields. Start counting character positions from 0.
For example -f 1 -c 2-3 would sort on the third and
fourth characters of the second field. Several
character ranges may be specifed for a given field.
For example -f 2 -c 5-6 -c 3-4 -c 1-2 would specify
three sorting fields of 2 characters each with the
third delimited field. When specifying a character
range within a field, the second number must be greater
or larger than the first. ie. -c 7-3 cannot be used.
An indefinite character range can be specified as
in -c 4- . This will indicate all characters starting
with the fifth to the end of the field.
.ti -4
<range> a range is used to specify ranges of fields, displacements
within a field and collating values. The common syntax is
<start>[-[<end>]] . <start> indicates a single value. <start>-
indicates a range beginning at <start> to a large number. For
example -f 2- would be used to specify all fields after the
second. <start>-<end> indicates a range of fields. The
start and end number can be in a number of formats:
simple decimal numbers, numbers starting with 0 are taken
to be octal, numbers starting with 0x are taken to be
hexidecimal and characters within apostrophes are converted
to there ascii value. Hence -k ' ' 'a'-'z' and -k 0x20 'a'-122
are equivalent.
.ti -4
-d the following character is the field delimiter. For example
-d '|' . The default field delimiter is a tab (0x09).
.in -4
Sorting proceeds according to the precedence indicated by
the sequence of the sorting fields.
Records with the same sorting fields
will be output in an unpredictable sequence.
Remember that characters not specified within a collating
sequence are taken as collating value zero.
This can result in unexpected behavior when fields
are not the same length. Following is the result of
sorting a small file with -k 'z'-'a'.
.nf
def
cad
basdf
a
aa
.fi
This was probably not the result intended. To get the
desired result, use -k 'a'-'z' -i.
.nf
def
cad
basdf
aa
a